Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codemirror/commands

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/commands

Collection of editing commands for the CodeMirror code editor

  • 6.7.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
250K
decreased by-80.67%
Maintainers
2
Weekly downloads
 
Created

What is @codemirror/commands?

@codemirror/commands is a package that provides a collection of commands for the CodeMirror code editor. These commands are used to manipulate the editor's content, navigate through the text, and perform various editing operations. The package is designed to be used with the CodeMirror 6 framework.

What are @codemirror/commands's main functionalities?

Basic Editing Commands

This feature includes basic editing commands such as inserting a newline and deleting a character forward. The code sample demonstrates how to bind these commands to specific keys in a CodeMirror editor instance.

import { insertNewline, deleteCharForward } from '@codemirror/commands';

// Example usage in a CodeMirror setup
const editor = new EditorView({
  state: EditorState.create({
    doc: 'Hello, world!',
    extensions: [
      keymap.of([{
        key: 'Enter', run: insertNewline
      }, {
        key: 'Delete', run: deleteCharForward
      }])
    ]
  }),
  parent: document.body
});

Selection Commands

This feature includes commands for selecting text, such as selecting all text or selecting the current line. The code sample shows how to bind these commands to specific key combinations in a CodeMirror editor instance.

import { selectAll, selectLine } from '@codemirror/commands';

// Example usage in a CodeMirror setup
const editor = new EditorView({
  state: EditorState.create({
    doc: 'Hello, world!',
    extensions: [
      keymap.of([{
        key: 'Ctrl-a', run: selectAll
      }, {
        key: 'Ctrl-l', run: selectLine
      }])
    ]
  }),
  parent: document.body
});

Navigation Commands

This feature includes navigation commands such as moving the cursor left or right by one character. The code sample demonstrates how to bind these commands to the arrow keys in a CodeMirror editor instance.

import { cursorCharLeft, cursorCharRight } from '@codemirror/commands';

// Example usage in a CodeMirror setup
const editor = new EditorView({
  state: EditorState.create({
    doc: 'Hello, world!',
    extensions: [
      keymap.of([{
        key: 'ArrowLeft', run: cursorCharLeft
      }, {
        key: 'ArrowRight', run: cursorCharRight
      }])
    ]
  }),
  parent: document.body
});

Other packages similar to @codemirror/commands

Keywords

FAQs

Package last updated on 21 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc